package com.srwl.mytx.widget.chatRow;

import android.content.Intent;
import android.view.View;
import android.widget.TextView;

import com.alibaba.fastjson.JSONObject;
import com.srwl.mytx.Constant;
import com.srwl.mytx.Helper;
import com.srwl.mytx.activity.CoinTransferDetailActivity;
import com.srwl.mytx.domain.CoinTransfer;
import com.srwl.mytx.utils.Utils;
import com.srwl.mytx.R;


public class ChatRowTransfer extends BaseChatRow {

    private TextView mTvGreeting;
    private TextView tvTransferReceive;
    private CoinTransfer transfer;


    public ChatRowTransfer(View itemView) {
        super(itemView);

    }

    @Override
    protected void onInflateView() {


    }

    @Override
    protected void onFindViewById(View itemView) {
        mTvGreeting = itemView.findViewById(R.id.tv_money_greeting);
        tvTransferReceive = itemView.findViewById(R.id.tv_transfer);
    }

    @Override
    protected void onSetUpView() {

        transfer = JSONObject.parseObject(message.getContent(), CoinTransfer.class);
        //JSONObject jsonObject=JSONObject.parseObject(message.getContent());
        mTvGreeting.setText(isSendMessage ? R.string.transfer_msg_send : R.string.transfer_msg_receive);


        //mTvSponsorName.setText(sponsorName);
        tvTransferReceive.setText(String.format(context.getString(R.string.msg_transfer_from_you), Utils.moneyFormat(transfer.getAmount())));
        if (!isSendMessage && message.getReadState() == Constant.MESSAGE_READ_STATE_UNREAD&& chatRowCallBack != null) {
            //  message.setMsgReadStatus(2);
            chatRowCallBack.onMessageRead(message);

            Helper.getInstance().syncUserInfo();
        }
    }


    @Override
    protected void onUpdateView() {

    }

    @Override
    protected void onBubbleClick() {

        activity.startActivity(new Intent(context, CoinTransferDetailActivity.class).putExtra(Constant.EXTRA_TRANSFER_INFO, transfer));


    }

}
